/**
 * @将字符串转换为对应整数的函数
 *
 * @author	 wangshikun <wangshikun2010@gmail.com>
 * @copyright	(c) 2012 wangshikun <wangshikun2010@gmail.com>
 * @license	http://www.opensource.org/licenses/mit-license.php The MIT License
 * @package	default
 * @subpackage	default
 */

#include <stdio.h>
#include <cs50.h>

int strtoInt(const char string[]);

int main(int argc, char *argv[]) {
	printf("%d\n", strtoInt("245"));
	printf("%d\n", strtoInt("100") + 25);
	printf("%d\n", strtoInt("13x5"));
	return 0;
}

int strtoInt(const char string[]) {
	int i, intValue,result = 0;

	for (i=0; string[i] >= '0' && string[i] <= '9'; i++) {
		intValue = string[i] - '0';
		result = result * 10 + intValue;
	}

	return result;
}
